package com.xiaouyudeguang.common.utils;

import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.ConfigurableEnvironment;

@Configuration
public class EnvironmentUtils {

    private static final String NAMESPACE = "spring.cloud.nacos.discovery.namespace";

    private static ConfigurableEnvironment environment;

    public EnvironmentUtils(ConfigurableEnvironment environment) {
        EnvironmentUtils.environment = environment;
    }

    public static ConfigurableEnvironment getEnvironment() {
        return environment;
    }

    public static String getProperty(String key) {
        return environment.getProperty(key);
    }

    public static String getNamespace() {
        return environment.getProperty(NAMESPACE);
    }

    public static boolean isLocal() {
        return System.getProperty("os.name").toLowerCase().contains("windows");
    }
}
